package LogisticsSystem.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import LogisticsSystem.mapper.OrdersMapper;
import LogisticsSystem.mapper.ext.OrderExtendMapper;
import LogisticsSystem.mapper.OrderdetailMapper;
import LogisticsSystem.po.Orders;
import LogisticsSystem.po.OrdersExample;
import LogisticsSystem.po.ext.OrderExtend;
import LogisticsSystem.po.Orderdetail;
import LogisticsSystem.po.OrderdetailExample;
import LogisticsSystem.service.ServiceStaffService;

@Service
public class ServiceStaffServiceImpl implements ServiceStaffService {
	@Autowired
	private OrdersMapper orderMapper;
	@Autowired
	private OrderdetailMapper orderdetailMapper;
	@Autowired
	private OrderExtendMapper orderExtendMapper;

	/**
	 * 返回所有订单状态为0，即是配送请求的订单
	 */
	public List<Orders> showOrder0() throws Exception {
		OrdersExample orderExample = new OrdersExample();
		LogisticsSystem.po.OrdersExample.Criteria createCriteria = orderExample.createCriteria();
		createCriteria.andOStatusEqualTo(0);
		List<Orders> order0 = orderMapper.selectByExample(orderExample);
		if (order0.size() > 0) {
			return order0;
		}
		return null;
	}

	public List<Orderdetail> showOrderDetailByOrderId(Integer id) throws Exception {
		OrderdetailExample orderdetailExample = new OrderdetailExample();
		LogisticsSystem.po.OrderdetailExample.Criteria createCriteria = orderdetailExample.createCriteria();
		createCriteria.andOIdEqualTo(id);
		List<Orderdetail> order0 = orderdetailMapper.selectByExample(orderdetailExample);
		if (order0.size() > 0) {
			return order0;
		}
		return null;
	}

	@Override
	public List<OrderExtend> showOrderExtend0() {
		return orderExtendMapper.selectOrderExtendList0();
	}
}
